package com.itheima.mybatis.mapper;

import com.itheima.mybatis.bean.Student;
import com.itheima.mybatis.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentMapperImpl implements StudentMapper {
    SqlSession sqlSession = MyBatisUtils.getSqlSession();

    @Override
    public List<Student> findAll() {
        List<Student> list = sqlSession.selectList("StudentMapper.findAll");
        return list;
    }

    @Override
    public Student findById(Integer id) {
        return sqlSession.selectOne("StudentMapper.findById", id);
    }

    @Override
    public int insert(Student stu) {
        return sqlSession.insert("StudentMapper.insert", stu);
    }

    @Override
    public int delete(Integer id) {
        return sqlSession.delete("StudentMapper.delete", id);
    }

    @Override
    public int update(Student stu) {
        return sqlSession.update("StudentMapper.update", stu);
    }
}
